expanded on the comments for the map distance function