Fix recursion bug