implemented a nice layer for segmentations