fixed recursion bug.