Updated code based on feedback from code review.