add new functions for segmentation