Moved around the order of some code