refactored calculating the total miles