fix the segment bug