change greedy method into class