moved the array declaration out of the loop