Code optimization to increase performance