Optimized the performance by reducing object creation.