add some graphs and clean up data_write_function