main header logic