added recursive minimax function