Fixed the problem with the repositioning logic.