fixed buffer reference bug