Changed the way to define xhr method