bugfix: check if header exists before referencing