fix bug where state wouldn't change because of improper xhr handling