refactor tic-tac-toe