rearranged code order