further refactor streaming