my algorithm for segmentation.