add segment length getter function that may be too slow