optimize buffer