moved logic to player.js