fix write buffer