working version of Greedy Search algorithm - testing required