add stream state management