Fixed variables with typos. Added nested loop.
Merge pull request #1 from icecreammatt/master

Fixed variables with typos. Added nested loop.