change order of code for clarity