anchor.diff:    implicit none
     integer :: i,j,k
     double precision :: Hjk, Hki, Hij, pre(N_det_ref), wall
  -  integer :: i_state, degree, npre, ipre(N_det_ref)
  +  integer :: i_state, degree, npre, ipre(N_det_ref), npres(N_det_ref)
     
     provide lambda_mrcc
  -
  +  npres = 0
     delta_cas = 0d0
     call wall_time(wall)
  -  print *, wall
  +  print *, "dcas ", wall
     do i_state = 1, N_states
  -    !$OMP PARALLEL DO default(none) schedule(dynamic) private(pre,npre,ipre,j,k,Hjk,Hki,degree) shared(no_mono_dressing,lambda_mrcc,i_state, N_det_non_ref,psi_ref, psi_non_ref,N_int,delta_cas,N_det_ref)
  +    !$OMP PARALLEL DO default(none) schedule(dynamic) private(pre,npre,ipre,j,k,Hjk,Hki,degree) shared(npres,lambda_mrcc,i_state, N_det_non_ref,psi_ref, psi_non_ref,N_int,delta_cas,N_det_ref)
       do k=1,N_det_non_ref
         if(lambda_mrcc(i_state, k) == 0d0) cycle
         npre = 0
         do i=1,N_det_ref
           call i_h_j(psi_non_ref(1,1,k),psi_ref(1,1,i), N_int,Hki)
           if(Hki /= 0d0) then
  +          !$OMP ATOMIC
  +          npres(i) += 1
             npre += 1
             ipre(npre) = i
             pre(npre) = Hki
           end if
         end do
  +      
  +      
         do i=1,npre
         do j=1,i
           !$OMP ATOMIC
  
positive.code:   
    integer :: II, blok
    
    provide det_cepa0_active delta_cas lambda_mrcc
    provide mo_bielec_integrals_in_map
    allocate(idx_sorted_bit(N_det))
  
negative.code: 
   BEGIN_PROVIDER [ double precision, delta_ij_old, (N_det_ref,N_det_non_ref,N_states) ]
  &BEGIN_PROVIDER [ double precision, delta_ii_old, (N_det_ref,N_states) ]
    implicit none
    
    integer                         :: i_state, i, i_I, J, k, kk, degree, degree2, m, l, deg, ni
    integer                         :: p1,p2,h1,h2,s1,s2, blok
    integer, allocatable            :: linked(:,:), blokMwen(:, :), nlink(:)
    logical                         :: ok
    double precision                :: phase_iI, phase_Ik, phase_Jl, phase_IJ, phase_al, diI, hIi, hJi, delta_JI, dkI(N_states), HkI, ci_inv(N_states), dia_hla(N_states)
    double precision                :: contrib, wall, iwall
    integer, dimension(0:2,2,2)     :: exc_iI, exc_Ik, exc_IJ
    integer(bit_kind)               :: det_tmp(N_int, 2), det_tmp2(N_int, 2), inac, virt
    integer, allocatable :: idx_sorted_bit(:)
    integer, external               :: get_index_in_psi_det_sorted_bit, searchDet
    logical, external               :: is_in_wavefunction, isInCassd
    
    
    call wall_time(iwall)
    allocate(idx_sorted_bit(N_det))
    allocate(linked(N_det_non_ref, N_det_ref), blokMwen(N_det_non_ref, N_det_ref), nlink(N_det_ref))
    
    idx_sorted_bit(:) = -1
    do i=1,N_det_non_ref
  