anchor.diff:        k = det_cepa0_idx(linked(kk, i_I))
         blok = blokMwen(kk, i_I)
         
  -      call get_excitation(psi_ref(1,1,i_I),psi_non_ref(1,1,k),exc_Ik,degree,phase_Ik,N_int)
  +      call get_excitation(psi_ref(1,1,i_I),psi_non_ref(1,1,k),exc_Ik,deg,phase_Ik,N_int)
       
         if(J /= i_I) then
           call apply_excitation(psi_ref(1,1,J),exc_Ik,det_tmp2,ok,N_int)
  
positive.code:         call apply_excitation(psi_non_ref(1,1,i),exc_Ik,det_tmp,ok,N_int)
          if(.not. ok) cycle
          if(HP(1,i) + HP(1,k) <= 2 .and. HP(2,i) + HP(2,k) <= 2) then
            cycle
          end if
          
          !if(isInCassd(det_tmp, N_int)) cycle
            
          do i_state = 1, N_states 
            !if(lambda_mrcc(i_state, i) == 0d0) cycle
            
  
            !contrib = h_cache(i_I,k) * lambda_mrcc(i_state, k) * dleat(i_state, m, 2)! * phase_al
            contrib =  dij(i_I, k, i_state) * dleat(i_state, m, 2)
            contrib_s2 =  dij(i_I, k, i_state) * dleat_s2(i_state, m, 2)
            delta(i_state,ll,1) += contrib
            delta_s2(i_state,ll,1) += contrib_s2
            if(dabs(psi_ref_coef(i_I,i_state)).ge.5.d-5) then
  
negative.code:   integer, allocatable           :: hp(:,:)
  
  
    integer                         :: i_state, i, i_I, J, k, k2, k1, kk, ll, m, l, deg, ni, m2
    integer                         :: n(2)
    integer                         :: p1,p2,h1,h2,s1,s2, blok, I_s, J_s, kn
    logical                         :: ok
    double precision                :: phase_ia, phase_Ik, phase_Jl, phase_Ji, phase_la, phase_ka, phase_tmp
    double precision                :: Hka, Hla, Ska, Sla, tmp
    double precision                :: diI, hIi, hJi, delta_JI, dkI, HkI, ci_inv(N_states), cj_inv(N_states)
    double precision                :: contrib, contrib_s2, wall, iwall
    integer, dimension(0:2,2,2)     :: exc_iI, exc_Ik, exc_IJ, exc
    integer(bit_kind)               :: det_tmp(N_int, 2), det_tmp2(N_int, 2), inac, virt
    integer, external               :: get_index_in_psi_det_sorted_bit, searchDet, detCmp
    logical, external               :: is_in_wavefunction
    integer,allocatable :: komon(:)
    logical :: komoned
    !double precision, external :: get_dij
  