added code to track and print the list of segments (hopefully in order)