implement game logic