fixed some bugs with xhr