diff --git a/notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb b/notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb
index a14dea206177ba49c37437b3ec1dfa744d0811a6..bec0026e29a9d5054a86c107494fa9e848041337 100644
--- a/notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb
+++ b/notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb
@@ -537,6 +537,21 @@
     "    }"
    ]
   },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "# set the operating condition\n",
+    "# note: iCalibrationDB only adds gain_mode if it is truthy, so we don't need to handle None\n",
+    "condition = Conditions.Dark.AGIPD(memory_cells=max_cells,\n",
+    "                                  bias_voltage=bias_voltage,\n",
+    "                                  acquisition_rate=acq_rate,\n",
+    "                                  gain_setting=gain_setting,\n",
+    "                                  gain_mode=(True if fixed_gain_mode else None))"
+   ]
+  },
   {
    "cell_type": "code",
    "execution_count": null,
@@ -553,7 +568,6 @@
     "detinst = getattr(Detectors, dinstance)\n",
     "\n",
     "print('Retrieve pre-existing constants for comparison.')\n",
-    "\n",
     "for qm in res:\n",
     "    qm_db = qm_dict[qm]\n",
     "    karabo_da = qm_db[\"karabo_da\"]\n",
@@ -561,13 +575,6 @@
     "        dconst = getattr(Constants.AGIPD, const)()\n",
     "        dconst.data = res[qm][const]\n",
     "\n",
-    "        # Setting conditions\n",
-    "        condition = Conditions.Dark.AGIPD(memory_cells=max_cells,\n",
-    "                                          bias_voltage=bias_voltage,\n",
-    "                                          acquisition_rate=acq_rate,\n",
-    "                                          gain_setting=gain_setting,\n",
-    "                                          gain_mode=(True if fixed_gain_mode else None))\n",
-    "\n",
     "        # This should be used in case of running notebook\n",
     "        # by a different method other than myMDC which already\n",
     "        # sends CalCat info.\n",
@@ -611,12 +618,6 @@
     "        dconst = getattr(Constants.AGIPD, const)()\n",
     "        dconst.data = res[qm][const]\n",
     "\n",
-    "        # set the operating condition\n",
-    "        condition = Conditions.Dark.AGIPD(memory_cells=max_cells,\n",
-    "                                          bias_voltage=bias_voltage,\n",
-    "                                          acquisition_rate=acq_rate,\n",
-    "                                          gain_setting=gain_setting,\n",
-    "                                          gain_mode=(True if fixed_gain_mode else None))\n",
     "        if db_output:\n",
     "            md = send_to_db(db_module, karabo_id, dconst, condition, file_loc,\n",
     "                            report, cal_db_interface, creation_time=creation_time,\n",