fix variables, fix execution order