added early exit loop case