Fix wrong order of execution