refactoring XHR