Fix wrong code of stream check