rewrite massive html output using heredoc