Deduped more code and made function static in Mappr for reuse