Refactored to improve readability.