Please move this function out of handleStream. No other modules define nested functions like this.