swapped out for loop for array