rearranged code