refactor page header code