Refactor player.js