store intermediate in temp, append that to output