position tracking implementation and refactoring