rearrange output