before adding greedy algorithm