fix minor problem with loop