repair Loop example (seems to work OK now)