Refactor spawnPlayer