diff --git a/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb b/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb
index 5ef0c5b28f63a598a4809547edaf703e47c9eeb5..e62e407456f015457435690935ff1fd223ca5be8 100644
--- a/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb
+++ b/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb
@@ -574,32 +574,31 @@
    "metadata": {},
    "outputs": [],
    "source": [
-    "if round_photons:\n",
-    "    data_units = 'photon'\n",
-    "    litpx_threshold = 1.\n",
-    "    if not xray_gain:\n",
-    "        litpx_threshold *= 7.\n",
-    "else:\n",
-    "    data_units = 'keV'\n",
-    "    if photon_energy_warn:\n",
-    "        warning(photon_energy_warn, '. Use 12 keV for lit-pixel counter threshold')\n",
-    "        litpx_threshold = 12.\n",
+    "if count_lit_pixels:\n",
+    "    if round_photons:\n",
+    "        data_units = 'photon'\n",
+    "        litpx_threshold = 1.\n",
     "    else:\n",
-    "        litpx_threshold = photon_energy\n",
-    "\n",
-    "    if rounding_threshold_warn:\n",
-    "        warning(rounding_threshold_warn)\n",
+    "        data_units = 'keV'\n",
+    "        if photon_energy_warn:\n",
+    "            warning(photon_energy_warn, '. Use 12 keV for lit-pixel counter threshold')\n",
+    "            litpx_threshold = 12.\n",
+    "        else:\n",
+    "            litpx_threshold = photon_energy\n",
     "\n",
-    "if not xray_gain:\n",
-    "    # convert photon energy to ADU (for AGIPD approx. 1 keV = 7 ADU)\n",
-    "    # it looks that rounding to photons can be applied to data in ADU as well\n",
-    "    litpx_threshold *= 7.\n",
-    "    data_units = 'ADU'\n",
+    "        if rounding_threshold_warn:\n",
+    "            warning(rounding_threshold_warn)\n",
     "\n",
-    "litpx_threshold *= rounding_threshold\n",
+    "    if not xray_gain:\n",
+    "        # convert photon energy to ADU (for AGIPD approx. 1 keV = 7 ADU)\n",
+    "        # it looks that rounding to photons can be applied to data in ADU as well\n",
+    "        litpx_threshold *= 7.\n",
+    "        data_units = 'ADU'\n",
     "\n",
-    "if count_lit_pixels:\n",
-    "    print(f\"Count lit-pixels with signal above {litpx_threshold:.3g} {data_units}\")"
+    "    litpx_threshold *= rounding_threshold\n",
+    "    print(f\"Count lit-pixels with signal above {litpx_threshold:.3g} {data_units}\")\n",
+    "else:\n",
+    "    litpx_threshold = 1e20"
    ]
   },
   {