rearrange structure of code