Added header handling code