re-arrange segments