modified stopping condition for recursion