Swap forEach for for loop