Refactored player.js