outsources some code to Output.js to use it in HTMLOutput.js too
changes