Refactor mouse position calculator method