Code that was a little bit adopted for tic-tac-toe