improve greedy.py