trying to fix problem with tot_res_output

Not working yet