Refactored after review.