Given an existing block of code, analyze its efficiency, identify the performance bottlenecks, and refactor it for better performance.