Refactor code as suggested in code review.