Refactored to move all segments together.