implement the game flow logic