update buffer function