added ability to specify number of segments OR segment length
