change linkdistance function