Extracted code out into add_headers and add_value to make it more maintenable.