refactors the positioning code