fixed the looping