parallel implementation of the "segment" function of package