more precise infinite recursion prevention