changed the distance method