refine code, pass stream id.