diff --git a/notebooks/pnCCD/Correct_pnCCD_NBC.ipynb b/notebooks/pnCCD/Correct_pnCCD_NBC.ipynb
index 670bbcfb10356e47ae88b04d35e5b626031556e4..98d913e17fa78bcc682b55d26f7fe1cf3773db8e 100644
--- a/notebooks/pnCCD/Correct_pnCCD_NBC.ipynb
+++ b/notebooks/pnCCD/Correct_pnCCD_NBC.ipynb
@@ -325,17 +325,16 @@
     "\n",
     "if relgain:\n",
     "    try:\n",
-    "        pnccd_metadata = pnccd_cal.metadata(calibrations=[\"RelativeGainCCD\"])\n",
+    "        gain_metadata = pnccd_cal.metadata(calibrations=[\"RelativeGainCCD\"])\n",
+    "        for mod, md in gain_metadata.items():\n",
+    "            for cname, c_md in md.items():\n",
+    "                pnccd_metadata[mod][cname] = c_md\n",
     "    except CalCatError as e:  # TODO: fix after getting new exceptions.\n",
     "        warning(f\"{e} While asking for {pnccd_cal.illuminated_calibrations}\")\n",
     "        warning(\"RelativeGainEPix100 is not retrieved from the calibration database. \"\n",
     "                \"Relative gain correction is disabled.\")\n",
     "        corr_bools['relgain'] = False\n",
     "\n",
-    "\n",
-    "\n",
-    "metadata = pnccd_metadata[karabo_da]\n",
-    "\n",
     "mod_to_pdu = pnccd_cal.mod_to_pdu\n",
     "ccvs_url = \"https://in.xfel.eu/calibration/calibration_constant_versions/\"\n",
     "for mod, mod_md in pnccd_metadata.items():\n",
@@ -344,6 +343,8 @@
     "        display(Markdown(\n",
     "            f\"- [{cname}]({ccvs_url}/{c_mdata['ccv_id']}): {c_mdata['begin_validity_at']}\"))\n",
     "\n",
+    "metadata = pnccd_metadata[karabo_da]\n",
+    "\n",
     "# Validate the constants availability and raise/warn correspondingly. \n",
     "missing_dark_constants = set(\n",
     "    c for c in pnccd_cal.dark_calibrations if c not in metadata.keys())\n",