Positioning code refactored