   for(int idx=0; idx< full_dm_list.size(); idx += ndm_trial_gulp){
 
     int start = idx;
-    int end   = idx + ndm_trial_gulp; 
-
-    end = end > full_dm_list.size() ? full_dm_list.size() : end;
-
-    if(args.verbose)
-    std::cout << "Gulp start: " << start << " end: " << end << std::endl;
+    int end   = (idx + ndm_trial_gulp) > full_dm_list.size() ? full_dm_list.size(): (idx + ndm_trial_gulp) ; 
+
+    if(args.verbose) std::cout << "Gulp start: " << start << " end: " << end << std::endl;
 
     std::vector<float> dm_list_chunk(full_dm_list.begin() + start,  full_dm_list.begin() + end);
+
+    Dedisperser dedisperser(filobj,nthreads);
     dedisperser.set_dm_list(dm_list_chunk);
 
     if (args.verbose){

    printf("Complete (execution time %.2f s)\n",timers["reading"].getTime());
  }


  Dedisperser dedisperser(filobj,nthreads);
  DMDistiller dm_still(args.freq_tol,true);
  HarmonicDistiller harm_still(args.freq_tol,args.max_harm,true,false);
  CandidateCollection dm_cands;

    std::cout << "Executing dedispersion" << std::endl;
    }

    if (args.progress_bar) printf("Starting dedispersion...\n");

    timers["dedispersion"].start();
    PUSH_NVTX_RANGE("Dedisperse",3)
