working game logic