'Greedy' implementation