Minor changes to looping script