Fixed error when stream is None