recursion bug fix