Extracted the maximum subsequence segmentation algorithms from the extract_maximum_subsequence function into a seperate one.