Updated the map function