optimized the code.