added a total distance to the output