Simplify the on_data_write event handler.