Optimize code to decrease loading time