Updated with performance analysis.