finished condition 2 for greedy