Rearrange of code