modify greedy, almost done with minimax