Optimization all_of and any_of