added batch writing