fixed buffer bug