Switch forEach to map