added bounds-check for degenerate segmentations