diff --git a/loop/src/ccd.cc b/loop/src/ccd.cc
index a4aab643fd86ca626e63f8eb16ae45e82eda5614..ed8cf59f3e3f3e9a1a92c39144160869405cd462 100644
--- a/loop/src/ccd.cc
+++ b/loop/src/ccd.cc
@@ -270,11 +270,14 @@ bool CCD::SimpleClose(BackboneList& bb_list){
 
     //handle res_index = num_residues-1
     uint res_index = num_residues-1;
+    actual_positions[0] = bb_list.back().n_coord; 
+    actual_positions[1] = bb_list.back().ca_coord;
+    actual_positions[2] = bb_list.back().c_coord;
     anchor = bb_list[res_index].ca_coord;
     rotation_bond = bb_list[res_index].ca_coord - bb_list[res_index].n_coord;
     d_phi = GetRotationAngle(actual_positions, anchor, rotation_bond, target_positions_);
     if(std::abs(d_phi) > 1e-6) bb_list.RotateAroundPhiTorsion(res_index, d_phi,true);
-
+    
     if(GetTargetMSD(bb_list, target_positions_) < squared_cutoff){
       return true;
     }