Improve the optimized version