update greedy algorithm