Refactored to make it more readable