code cleanup in addSegment(). Reversed the if/else logic for clarity