Greedy alghoritm implemented