Reduce duplication? There's both `if` and `while` examples below.