fix streaming function