Optimizing code based on Michael's recommendation.