fix segmentation, partitioning