fix write bug

fix two write bugs