fix bugs for buf