Refactored to have the validation inside the Segment class