Refactor change position code