added a game class, code refactoring