unify stream handling