Fix loop bug (closes #1).
Merge pull request #2 from yasuhito/feature/fix_loops

Fix loop bug (closes #1).