diff --git a/xgm.py b/xgm.py
index 506bfccc1a675609cc0f22bc5b8339732f4eef33..881b8bd7869723d9d5fbfdf182f85ffe7d2db194 100644
--- a/xgm.py
+++ b/xgm.py
@@ -609,12 +609,10 @@ def getTIMapd(data, mcp=1, use_apd=True, intstart=None, intstop=None,
                             'SCS_UTC1_ADQ/ADC/1', 'board1.apd.channel_0.upperLimit.value')[0].values
             period = upperLimit - initialDelay #period of the apd in number of digitizer samples
             idx /= int(period/440) #440 samples correspond to the separation between two pulses at 4.5 MHz
-            if len(idx)==1:
-                idx = idx[0].astype(int)
-                tim = apd.isel(apdId=idx)
-                return tim
+            idx = idx[0].astype(int)
+            return apd.isel(apdId=idx)
         else:
-            apd = mcpPeaks(data, intstart, intstop, bkgstart, bkgstop, mcp=mcp, 
+            return mcpPeaks(data, intstart, intstop, bkgstart, bkgstop, mcp=mcp, 
                            t_offset=t_offset, npulses=maxpulses)
     
     #2. case where the number of SASE 3 pulses varied during the run: