Replace with optimized version