rewrite loop to go through only once
Merge pull request #1 from dimagi/rewrite-loop

rewrite loop to go through only once