Code changed to forEach style