separated segmentation functions in new file