Changed problem 2 script to loop a dynamic number of times