Not sure this is the right place.  But we should be using get app by uuid rather than get all apps in the domain and loop across.