Adding option to average distances taken at identical sample points