header parsing refactoring