rearrange the code