improved / extended header logic