added local position and refactored