diff --git a/notebooks/AGIPD/AGIPD_Retrieve_Constants_Precorrection.ipynb b/notebooks/AGIPD/AGIPD_Retrieve_Constants_Precorrection.ipynb
index 3b55820bdf66e55c2668eb76616e6551ef99fb37..7e7489309c6d56c9250e3d4a0544d430f3c51994 100644
--- a/notebooks/AGIPD/AGIPD_Retrieve_Constants_Precorrection.ipynb
+++ b/notebooks/AGIPD/AGIPD_Retrieve_Constants_Precorrection.ipynb
@@ -181,9 +181,7 @@
     "instr_dc = run_dc.select(instrument_src.format(\"*\"), require_all=True)\n",
     "\n",
     "if len(instr_dc.train_ids) == 0:\n",
-    "    raise ValueError(f\"No images found for {in_folder / f'r{run:04d}'}\")\n",
-    "# Used to later identify sources without images to skip.\n",
-    "available_sources = list(instr_dc.all_sources)"
+    "    raise ValueError(f\"No images found for {in_folder / f'r{run:04d}'}\")"
    ]
   },
   {
@@ -235,8 +233,8 @@
     "            mem_cells: number of memory cells.\n",
     "            mdata_dict: (DICT) dictionary with the metadata for the retrieved constants.\n",
     "    \"\"\"\n",
-    "\n",
-    "    if instrument_src.format(idx) not in available_sources:\n",
+    "    # check if this module has images to process.\n",
+    "    if instrument_src.format(idx) not in instr_dc.all_sources:\n",
     "        print(\"ERROR: No raw images found for \"\n",
     "              f\"{tools.module_index_to_qm(idx)}({k_da}).\")\n",
     "\n",