Fix buffer bug