improved loop breaking