Working on Recursive Algorithm