Sometimes loops can get quite complex with lots of conditional logic and deep nesting.  Have a look at this video for a technique to reduce this complexity.