Improved Xhr implementation