refactor game.js