use proper for loops for arrays