removed transplanted code from distance