It would probably be better to make this function always return a deferred rather than sometimes blocking and sometimes not.