fixed a logic error in update header.