add_data_output use global vars, needs more changes