Refactor game.js