checking stream before creating it