diff --git a/cal_tools/cal_tools/agipdlib.py b/cal_tools/cal_tools/agipdlib.py
index 84bc94255fcee20b0680116306c45032a9c5fac7..5ac64e76d2636a50f9326dddaf6b9112283e99a1 100644
--- a/cal_tools/cal_tools/agipdlib.py
+++ b/cal_tools/cal_tools/agipdlib.py
@@ -72,8 +72,8 @@ class AgipdCorrections:
     """
 
     def __init__(self, infile, outfile, max_cells, channel, max_pulses,
-                 bins_gain_vs_signal, bins_signal_low_range,
-                 bins_signal_high_range,
+                 rng_pulse_idx, bins_gain_vs_signal,
+                 bins_signal_low_range, bins_signal_high_range,
                  bins_dig_gain_vs_signal, raw_fmt_version=2, chunk_size=512,
                  h5_data_path="INSTRUMENT/SPB_DET_AGIPD1M-1/DET/{}CH0:xtdf/",
                  h5_index_path="INDEX/SPB_DET_AGIPD1M-1/DET/{}CH0:xtdf/",
@@ -91,7 +91,8 @@ class AgipdCorrections:
         :param max_cell: maximum number of memory cells to handle, e.g. if
                          calibration constants only exist for a subset of cells
         :param channel: module/channel to correct
-        :param max_pulses: maximum pulse id to consider for preview histograms
+        :param max_pulses: pulse indices to consider for preview histograms
+        :param rng_pulse_idx: maximum pulse idx to consider for preview histograms
         :param bins_gain_vs_signal: number of bins for gain vs signal histogram
         :param bins_signal_low_range: number of bins for the low signal
             range histogram
@@ -121,6 +122,7 @@ class AgipdCorrections:
         self.chunksize = chunk_size
         self.initialized = False
         self.max_pulses = max_pulses
+        self.rng_pulse_idx = rng_pulse_idx
         self.max_cells = max_cells
         self.hists_signal_low = 0
         self.hists_signal_high = 0
@@ -1031,16 +1033,16 @@ class AgipdCorrections:
         if cidx == 0:
             copim = copy.copy(im)
             copim[copim < self.median_noise] = np.nan
-            bins = (self.bins_signal_low_range, self.max_pulses)
-            rnge = [[-50, 1000], [0, self.max_pulses + 1]]
+            bins = (self.bins_signal_low_range, self.rng_pulse_idx)
+            rnge = [[-50, 1000], [self.max_pulses[0], self.max_pulses[-1]]]
             H, xe, ye = np.histogram2d(np.nanmean(copim, axis=(1, 2)),
                                        pulseId,
                                        bins=bins,
                                        range=rnge)
             self.hists_signal_low += H
             self.low_edges = (xe, ye)
-            bins = (self.bins_signal_high_range, self.max_pulses)
-            rnge = [[0, 200000], [0, self.max_pulses + 1]]
+            bins = (self.bins_signal_high_range, self.rng_pulse_idx)
+            rnge = [[0, 200000], [self.max_pulses[0], self.max_pulses[-1]]]
             H, xe, ye = np.histogram2d(np.nanmean(copim, axis=(1, 2)),
                                        pulseId,
                                        bins=bins,
@@ -1159,7 +1161,7 @@ class AgipdCorrections:
 
 
         can_calibrate = (allcells < max_cells)
-        can_calibrate &= (allpulses < np.max(allpulses[:self.max_pulses]))
+        can_calibrate &= (allpulses < np.max(allpulses[np.array(self.max_pulses)]))
         
         if np.count_nonzero(can_calibrate) == 0:
             return
diff --git a/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb b/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb
index af85abf7dfe201047a54d2d06a46d790dea57564..59971159399109e659f8cae05001d086fd5b289e 100644
--- a/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb
+++ b/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb
@@ -22,9 +22,9 @@
    },
    "outputs": [],
    "source": [
-    "in_folder = \"/gpfs/exfel/exp/SPB/201901/p002545/raw\" # the folder to read data from, required\n",
-    "run = 9 # runs to process, required\n",
-    "out_folder =  \"/gpfs/exfel/data/scratch/karnem/AGIPD_Corr12\"  # the folder to output to, required\n",
+    "in_folder = \"/gpfs/exfel/exp/MID/201931/p900090/raw\" # the folder to read data from, required\n",
+    "run = 552 # runs to process, required\n",
+    "out_folder =  \"/gpfs/exfel/data/scratch/ahmedk/test/AGIPD_Corr\"  # the folder to output to, required\n",
     "calfile =  \"/gpfs/exfel/data/scratch/haufs/agipd_on_demand/agipd_store_mid.h5\" # path to calibration file. Leave empty if all data should come from DB\n",
     "sequences =  [-1] # sequences to correct, set to -1 for all, range allowed\n",
     "mem_cells = 0 # number of memory cells used, set to 0 to automatically infer\n",
@@ -32,7 +32,7 @@
     "overwrite = True # set to True if existing data should be overwritten\n",
     "no_relative_gain = False # do not do relative gain correction\n",
     "cluster_profile = \"noDB\"\n",
-    "max_pulses = 500\n",
+    "max_pulses = [0, 500, 1] # range list [st, end, step] of maximum pulse indices for the report histogram. 3 allowed maximum list input elements.   \n",
     "local_input = False\n",
     "bias_voltage = 300\n",
     "cal_db_interface = \"tcp://max-exfl016:8015#8045\" # the database interface to use\n",
@@ -348,7 +348,7 @@
     "from functools import partial\n",
     "def correct_module(max_cells, do_rel_gain, index_v, CHUNK_SIZE, total_sequences, sequences_qm, \n",
     "                   bins_gain_vs_signal, bins_signal_low_range, bins_signal_high_range,\n",
-    "                   bins_dig_gain_vs_signal, max_pulses, dbparms, fileparms, nodb, chunk_size_idim,\n",
+    "                   bins_dig_gain_vs_signal, max_pulses, rng_pulse_idx, dbparms, fileparms, nodb, chunk_size_idim,\n",
     "                   special_opts, il_mode, loc, dinstance, force_hg_if_below, force_mg_if_below,\n",
     "                   mask_noisy_adc, adjust_mg_baseline, acq_rate, dont_zero_nans, dont_zero_orange,\n",
     "                   inp):\n",
@@ -438,7 +438,7 @@
     "        infile = h5py.File(filename, \"r\", driver=\"core\")\n",
     "        outfile = h5py.File(filename_out, \"w\")\n",
     "        \n",
-    "        agipd_corr = AgipdCorrections(infile, outfile, max_cells, channel, max_pulses,\n",
+    "        agipd_corr = AgipdCorrections(infile, outfile, max_cells, channel, max_pulses, rng_pulse_idx,\n",
     "                                      bins_gain_vs_signal, bins_signal_low_range,\n",
     "                                      bins_signal_high_range, bins_dig_gain_vs_signal,\n",
     "                                      do_rel_gain=do_rel_gain, chunk_size_idim=chunk_size_idim,\n",
@@ -463,7 +463,6 @@
     "            return\n",
     "        if not nodb:\n",
     "            when = agipd_corr.initialize_from_db(dbparms, qm, only_dark=(fileparms != \"\"))\n",
-    "            print(when)\n",
     "        if fileparms != \"\":\n",
     "            agipd_corr.initialize_from_file(fileparms, qm, with_dark=nodb)\n",
     "        print(\"Initialized constants\")\n",
@@ -503,12 +502,39 @@
     "inp = []\n",
     "left = total_sequences\n",
     "\n",
+    "# check if max_pulses is a list, tuple or int.\n",
+    "# if list, then it's content are the requested pulse indices.\n",
+    "# if tuple, then it is a definition for a range of pulse indices.\n",
+    "# if int, then it is the max pulse indices starting 0.\n",
+    "\n",
+    "print(type(max_pulses))\n",
+    "if isinstance(max_pulses, list):\n",
+    "    if len(max_pulses) == 3:\n",
+    "        max_pulses = list(range(max_pulses[0],\n",
+    "                                max_pulses[1],\n",
+    "                                max_pulses[2]))\n",
+    "    elif len(max_pulses) == 2:\n",
+    "        max_pulses = list(range(max_pulses[0],\n",
+    "                                max_pulses[1],\n",
+    "                                1))\n",
+    "    elif len(max_pulses) == 1:\n",
+    "        rng_pulse_idx = max_pulses[0]\n",
+    "        max_pulses = list(range(max_pulses[0]))\n",
+    "\n",
+    "    else:\n",
+    "        raise ValueError(\"Wrong input for max_pulses {} \\n\".format(max_pulses),\n",
+    "                         \"max_pulses tuple has more than 3 arguments\")\n",
+    "    rng_pulse_idx = len(max_pulses)\n",
+    "elif isinstance(max_pulses, int):\n",
+    "    rng_pulse_idx = max_pulses\n",
+    "    max_pulses = list(range(max_pulses))\n",
+    "    \n",
     "bins_gain_vs_signal = (100, 100)\n",
     "bins_signal_low_range = 100\n",
     "bins_signal_high_range = 100\n",
     "bins_dig_gain_vs_signal = (100, 4)\n",
-    "hists_signal_low =  np.zeros((bins_signal_low_range, max_pulses), np.float64)\n",
-    "hists_signal_high =  np.zeros((bins_signal_low_range, max_pulses), np.float64)\n",
+    "hists_signal_low =  np.zeros((bins_signal_low_range, rng_pulse_idx), np.float64)\n",
+    "hists_signal_high =  np.zeros((bins_signal_low_range, rng_pulse_idx), np.float64)\n",
     "hists_gain_vs_signal =  np.zeros((bins_gain_vs_signal), np.float64)\n",
     "hists_dig_gain_vs_signal =  np.zeros((bins_dig_gain_vs_signal), np.float64)\n",
     "gain_stats = 0\n",
@@ -542,7 +568,7 @@
     "        print(\"Running {} tasks parallel\".format(len(inp)))\n",
     "        p = partial(correct_module, max_cells, do_rel_gain, index_v, CHUNK_SIZE, total_sequences,\n",
     "                    sequences_qm, bins_gain_vs_signal, bins_signal_low_range, bins_signal_high_range,\n",
-    "                    bins_dig_gain_vs_signal, max_pulses, dbparms, fileparms, nodb, chunk_size_idim,\n",
+    "                    bins_dig_gain_vs_signal, max_pulses, rng_pulse_idx, dbparms, fileparms, nodb, chunk_size_idim,\n",
     "                    special_opts, il_mode, loc, dinstance, force_hg_if_below, force_mg_if_below,\n",
     "                    mask_noisy_adc, adjust_mg_baseline, acq_rate, dont_zero_nans, dont_zero_orange)\n",
     "         \n",