adding the distance calculation