Refactored code for readability.