Refactory SegmentFactory class