Don't check iterator validity twice in a row