Simplified code in generate_output.js