refactoring game.js for more incapsulation