Refactor to improve readability and separate concerns, use Section enum and ordered traversal for consistent output.