add calculdistance function