Cleaned up minimax method