saving state better at the output generation phase