Refactoring to improve efficiency and readability.