Fixed recursion check