tic-tac-toe: improve event handling