Optimizing the speed of the program