externalize query change handling function