Refactors minimax