Switch forEach loop to for of syntax