created a deep map function