diff --git a/maxwell_integrate_to_h5.py b/maxwell_integrate_to_h5.py
index a2bb63f4575c6cf85182f4c02c93f5fc2cfaad85..69acb6a75ffafe421fca20e256e4a0e150c13176 100644
--- a/maxwell_integrate_to_h5.py
+++ b/maxwell_integrate_to_h5.py
@@ -167,9 +167,9 @@ def integrate_ims_in_dir(path_im, path_int, dtype_im=".tif", dtype_int=".dat"):
                     meas.attrs["axes"] = "q"
                     meas.attrs["filename"] = result["filename"]
 
-                    meas["I"] = h5py.SoftLink(f"/{subdir_name}/{entry_name}/instrument/detector/I")
-                    meas["q"] = h5py.SoftLink(f"/{subdir_name}/{entry_name}/instrument/detector/q")
-                    meas["dI"] = h5py.SoftLink(f"/{subdir_name}/{entry_name}/instrument/detector/dI")
+                    meas["I"] = h5py.SoftLink(f"/{entry_name}/instrument/detector/I")
+                    meas["q"] = h5py.SoftLink(f"/{entry_name}/instrument/detector/q")
+                    meas["dI"] = h5py.SoftLink(f"/{entry_name}/instrument/detector/dI")
 
                     # Optional display-friendly names
                     meas["I"].attrs["long_name"] = "Intensity"
@@ -181,8 +181,8 @@ def integrate_ims_in_dir(path_im, path_int, dtype_im=".tif", dtype_int=".dat"):
                     plotselect.attrs["signal"] = "I"
                     plotselect.attrs["axes"] = "q"
 
-                    plotselect["I"] = h5py.SoftLink(f"/{subdir_name}/{entry_name}/instrument/detector/I")
-                    plotselect["q"] = h5py.SoftLink(f"/{subdir_name}/{entry_name}/instrument/detector/q")
+                    plotselect["I"] = h5py.SoftLink(f"/{entry_name}/instrument/detector/I")
+                    plotselect["q"] = h5py.SoftLink(f"/{entry_name}/instrument/detector/q")
 
                     # Optional display-friendly names
                     plotselect["I"].attrs["long_name"] = "Intensity"
@@ -255,9 +255,7 @@ def integrate_ims_in_dir(path_im, path_int, dtype_im=".tif", dtype_int=".dat"):
             #         plot.create_dataset("dI", data=result["dI"])
             #         plot["dI"].attrs["long_name"] = np.string_("Uncertainty in I")
 
-            
-            h5.flush()
-            h5.close()
+
             print(f"✅ HDF5 file '{output_file}' created with {len(results_data)} spectra.")
             # # Sort results_data by filename
             # def natural_sort_key(item):