Improved output; truly greedy algorithm