diff --git a/maxwell_integrate_to_h5.py b/maxwell_integrate_to_h5.py
index 51c817a39778ddd558da96c2660d3a52c37d9ba5..a79f9ecf233519e02d9c2b621a9d5efd383ee5f0 100644
--- a/maxwell_integrate_to_h5.py
+++ b/maxwell_integrate_to_h5.py
@@ -125,29 +125,37 @@ def integrate_ims_in_dir(path_im, path_int, dtype_im=".tif", dtype_int=".dat"):
 
             # Prepare data for HDF5 file using silx
             hdf5_data = {
-                "entry": {
-                    "definition": "NXdata",
-                    "title": subdir_name,
-                    "data": {
-                        "@axes": "q",
-                        "@signal": "I",
-                        "@errors": "dI",
-                    }
+                subdir_name: {
+                    "@NX_class": "NXroot",
                 }
             }
 
-            for result in results_data:
-                filename_key = os.path.basename(result["filename"])
-                hdf5_data["entry"]["data"][filename_key] = {
-                    "q": result["q"].tolist(),
-                    "I": result["I"].tolist(),
-                    "dI": result["dI"].tolist()
+            # Sort results_data by filename
+            results_data = sorted(results_data, key=lambda x: x["filename"].lower())
+
+            for idx, result in enumerate(results_data, start=1):
+                group_name = f"{idx}.1"
+                hdf5_data[subdir_name][group_name] = {
+                    "@NX_class": "NXentry",
+                    "description": os.path.basename(result["filename"]),
+                    "measurements": {
+                        "@NX_class": "NXcollection",
+                        "q": result["q"].tolist(),
+                        "I": result["I"].tolist(),
+                        "dI": result["dI"].tolist()
+                    }
                 }
 
             # Save to HDF5 file using silx
             hdf5_file_path = os.path.join(subdir_path_int, f"{subdir_name}.h5")
             dicttoh5(hdf5_data, hdf5_file_path, mode="w")
 
+            print(f"Results for subdirectory {subdir_name} saved to HDF5 file using silx.")
+
+            # Save to HDF5 file using silx
+            hdf5_file_path = os.path.join(subdir_path_int, f"{subdir_name}.h5")
+            dicttoh5(hdf5_data, hdf5_file_path, mode="w")
+
             print(f"Results for subdirectory {subdir_name} saved to CSV and HDF5 files using silx.")
             del results_df
         else: