Implement greedy.