fixed more bugs in greedy version