added a for loop into the main section of the code