Refactoring: fixed the getTilePosition