optimizing loops
removing incorrect optimization
Merge pull request #1615 from shanethehat/loop-optimization

Optimizing loops