refactoring the game layer