cleaned up image segmentation