fixed a bug in iterative segmentation