I'd crack this function in the map out into a separate defn- as it is being used 2x.