distance function

function to calculate dist that Stephen wants