corrected reposition function