made changes to loop