anchor.diff:    integer, allocatable :: task_id(:)
     integer :: done, Nindex
     integer, allocatable :: index(:)
  -  real :: time, time0
  +  double precision :: time, time0, timeLast
  +  double precision, external :: omp_get_wtime
  +  integer :: tooth, firstTBDcomb, orgTBDcomb
  +  integer, allocatable :: parts_to_get(:)
  +  logical, allocatable :: actually_computed(:)
  +  
  +  allocate(actually_computed(N_det_generators), parts_to_get(N_det_generators))
  +  actually_computed = computed
  +  
  +  parts_to_get(:) = 1
  +  parts_to_get(1:10) = 8
  +
  +  do i=1,tbc(0)
  +    actually_computed(tbc(i)) = .false.
  +  end do
  +  
  +  orgTBDcomb = Nabove(1)
  +  firstTBDcomb = 1
  +
     zmq_to_qp_run_socket = new_zmq_to_qp_run_socket()
     zmq_socket_pull = new_zmq_pull_socket()
     allocate(val(b%N), det(N_int, 2, b%N), task_id(N_det), index(N_det))
     done = 0
     more = 1
  -  !pt2_detail = 0d0
  -  call CPU_TIME(time0)
  -  do while (more == 1)
  +  time0 = omp_get_wtime()
  +  timeLast = time0
  +  
  +  pullLoop : do while (more == 1)
       call pull_pt2_results(zmq_socket_pull, Nindex, index, pt2_mwen, task_id, ntask)
       do i=1,Nindex
         pt2_detail(:, index(i)) += pt2_mwen(:,i)
  +      parts_to_get(index(i)) -= 1
  +      if(parts_to_get(index(i)) < 0) then 
  +        stop "PARTS ??"
  +      end if
  +      if(parts_to_get(index(i)) == 0) actually_computed(index(i)) = .true.
       end do
  -    
  -    !do i=1, N
  -    !  call add_to_selection_buffer(b, det(1,1,i), val(i))
  -    !end do
   
       do i=1, ntask
         if(task_id(i) == 0) then
  
positive.code:       sum2above(j) += myVal**2
        Nabove(j) += 1
      end do
    end do
  end subroutine
  
  
  
negative.code:   time0 = omp_get_wtime()
    print *, "grep - time - avg - err - n_combs"
    do while(.true.)
      
      call new_parallel_job(zmq_to_qp_run_socket,"pt2")
      call zmq_put_psi(zmq_to_qp_run_socket,1,ci_electronic_energy,size(ci_electronic_energy))
      call zmq_set_running(zmq_to_qp_run_socket)
      call create_selection_buffer(1, 1*2, b)
      
  
      call get_carlo_workbatch(1d-2, computed, comb, Ncomb, tbc)
      generator_per_task = 1
      do i=1,tbc(0)
        i_generator_end = min(i+generator_per_task-1, tbc(0))
        if(tbc(i) > 10) then
          integer :: zero
          zero = 0
          write(task,*) (i_generator_end-i+1), zero, tbc(i:i_generator_end)
          call add_task_to_taskserver(zmq_to_qp_run_socket,task)
        else
          do j=1,8
            write(task,*) (i_generator_end-i+1), j, tbc(i:i_generator_end)
            call add_task_to_taskserver(zmq_to_qp_run_socket,task)
          end do
        end if
      end do
  
      print *, "tasked" 
      !$OMP PARALLEL DEFAULT(shared)  SHARED(b, pt2)  PRIVATE(i) NUM_THREADS(nproc+1)
        i = omp_get_thread_num()
        if (i==0) then
          call pt2_collector(b, tbc, comb, Ncomb, computed, pt2_detail, sumabove, sum2above, Nabove)
        else
          call pt2_slave_inproc(i)
        endif
      !$OMP END PARALLEL
      call end_parallel_job(zmq_to_qp_run_socket, 'pt2')
      tbc(0) = 0
    end do
  
    pt2 = 0d0
  end subroutine
  
  
  subroutine do_carlo(tbc, Ncomb, comb, pt2_detail, computed, sumabove, sum2above, Nabove)
    integer, intent(in) :: tbc(0:N_det_generators), Ncomb
    logical, intent(in) :: computed(N_det_generators)
    double precision, intent(in) :: comb(Ncomb), pt2_detail(N_states, N_det_generators)
    double precision, intent(inout) :: sumabove(comb_teeth), sum2above(comb_teeth), Nabove(comb_teeth)
    integer :: i, dets(comb_teeth)
    double precision :: myVal, myVal2
  
    mainLoop : do i=1,Ncomb
      call get_comb(comb(i), dets)
      do j=1,comb_teeth
        if(not(computed(dets(j)))) then
          exit mainLoop
        end if
      end do
      
      myVal = 0d0
      myVal2 = 0d0
      do j=comb_teeth,1,-1
  