This is very confusing code, since it's only side-effects. Why not return the header instead?