Refactoring for StreamHandler