Small efficiency change to any_duplicates