batch_write bug fix