new version, add buffer support