implemented rearrangement