remove_segment function

Remove segments