refactored Segment into 2 sub classes to simplify logic