Rearrange code