fixing 'detect empty stream' related error