modifed streaming.py