destroy stream; refactoring