Refactored into methods for readability