output/jack: move code to separate functions