the read/write function for SegmentSet work well.
reformat some code.