add buffer api,refactor