adding distance calculation function