move the close method to the segment object