Refactored to improve style.