added for loops to code