I reversed the order of the setNextTurn function call and checkForWinner function call and it works perfectly