Refactoring of XHR-Polling handlers into one handler