Code refactoring to reuse header value extraction