finished the basic segmentation