fix #24 foreach containing an if statement

This pull request fixes issue #24.