refactor streaming