Fixes #39 - check before looping