added ability to pass a stream as the source of the data