Separated the header building plus amended logic.