Fix cases at the end of the segment as well