splitting around segmentation to make code easier to read