Move iterator variable declaration to the point of use.
Move variable definition to the point just before it is needed.
Merge pull request #5 from ajbennieston/declare-vars-at-point-of-use

Declare variables at point of use