Use deferred to deal with slow ajax