final version of minimax