do header() calls before the echo output

depending on output buffering settings it may not work otherwise