Added a check for headers before parsing them