Formatted and refactored code for better readability.