upgraded distance calculations