move buffer logic into buffer module