Changed orders of some code