Implemented Greedy alghoritm