Refactor apply-minimax