`getNextSegment` and `nextSegment` are very similar names. We should consider how to make it clear what the difference between them is.

Maybe `getNextSegment` can be a private method too?