generate segments