Change to use greedy algorithm