rearrange code around header setting