fix a bug in greedy heuristics