improved handling for infinite rule recursion