add buffer
refactoring