Added deferred promise to dynamic function