Replace handler's references to 'this' with 'handler'
fixed write().end() chain in example