refactored game.js