updated to keep track of total distance, along with setting the start node as marked rather than always A