Changed order of some function calls