making loop-break work and adding a docstring