Refactors the player tiles javascript