fix a buffer bug