use "if-any" instead of for-loop with a flag