Calculation of total distance traveled