change linkdistance function
Merge remote-tracking branch 'upstream/master'