Updated forEach and map function