Improve js execution order