hw2 greedy is working