dry plus refactor of header code