code for next segment