Fix $q.when definition