update foreach to map