rearranged code

rearranged