fixed greedy step-wise merging