Changed code for minimax algorithm