rearrange and sort out