add debug into segment
debug
fix bugs in segment