changes to loop structure