Recursive Algorithm Seems to be working well