added code for naive segmentation