recursion bug fixed