Using old-fashioned loop in response to issue #138.
Fixed semantics of return value.
Fix for issue #135.