added stream closing