rewrite buffer to bucket brigade