reorganized header generation