replace xhr with $timeout