Attempting to refactor logic for headers