I had to modify this from what you suggested slightly to account for non-array value or null being returned from the plugin