updated array iteration with For Each loop