Fixed bug where ) would be left at the end of the segment