segment definition and generator script