anchor.diff:  
               end if
   
  +            ! 5. Calculate the excited determinant connection (can be up to degree 4)
  +            ! (i)   find the second excited determinant bitstring
  +            call create_excited_det(cdet_excit%f, connection_jk, f_excit_2)
  +            ! (ii)  calculate the connection to this excited determinant
  +            connection = get_excitation(cdet%f,f_excit_2)
  +
  +
  +         !******************* this code does not work in the case of looping back on itself *********************
               ! 5. Calculate the excited determinant (can be up to degree 4)
               ! (i)   add up the number of excitations
  -            connection%nexcit = connection_ki%nexcit + connection_jk%nexcit
  +!           connection%nexcit = connection_ki%nexcit + connection_jk%nexcit
               ! (ii)  combine the annihilations
  -            connection%from_orb(:connection_ki%nexcit) = &
  -                                connection_ki%from_orb(:connection_ki%nexcit)
  -
  -            connection%from_orb(connection_ki%nexcit+1:connection%nexcit) = &
  -                                connection_jk%from_orb(:connection_jk%nexcit)
  +!           connection%from_orb(:connection_ki%nexcit) = &
  +!                               connection_ki%from_orb(:connection_ki%nexcit)
  +
  +!           connection%from_orb(connection_ki%nexcit+1:connection%nexcit) = &
  +!                               connection_jk%from_orb(:connection_jk%nexcit)
   
               ! (iii) combine the creations
  -            connection%to_orb(:connection_ki%nexcit) = &
  -                                connection_ki%to_orb(:connection_ki%nexcit)
  -
  -            connection%to_orb(connection_ki%nexcit+1:connection%nexcit) = &
  -                                connection_jk%to_orb(:connection_jk%nexcit)
  +!           connection%to_orb(:connection_ki%nexcit) = &
  +!                               connection_ki%to_orb(:connection_ki%nexcit)
  +
  +!           connection%to_orb(connection_ki%nexcit+1:connection%nexcit) = &
  +!                               connection_jk%to_orb(:connection_jk%nexcit)
               
               
   
  
positive.code:         use determinants, only: det_info
          use excitations, only: excit
          use fciqmc_data, only: tau, H00
          use excitations, only: create_excited_det_complete
  
          type(det_info), intent(in) :: cdet
          integer, intent(in) :: parent_sign
          integer, intent(out) :: nspawn
  
negative.code:         type(excit)      :: connection_ki, connection_jk
          real(p)          :: psuccess, pspawn, pgen, hmatel
          type(det_info)   :: cdet_excit
  
          integer(i0)      :: f_excit_2(basis_length)
  
  
         ! specific to imperial code:
          !      -function that creates an excited determinant (create_excited_det)
  