refactored code of game class