pseudo code for segmenter