refactor as a transform stream