game logic refactor