Added function getTotalDistance()