detecting invalid streams