added game logic (restart and win detection)