Rearrange lines