Refactored according to review.