Rearrange the code