Refactoring game.js