Updated Recursion Part of the Algorithm

It should work fine now.