fix BufWriter and borrow check error