Fix conditional for reordering header fields

Original conditional was out of scope and never tested positive.
Replaced with a more lengthy but somewhat bullet-proof conditional.