rewrite to make sure buffer change happens