optimizations on for loops throughout code
for loop optimizations