Fixed broken version of the optimized code