added support for small buffering