Reorder some lines of code