rearrange code