Optimization of code