fix bugs in stream