Added Better Seglength Algorithm