replaced for loops with copy and pasted lines