Fixes #940: use label for breaking out of inner loop. Suggested by @LukeLin