Fixed buffer bug