Refactor to xmlhttprequest.js