improved header recognition