Fixed a segmentation stage and added the last step of processing