use:
```javascript
var contacts = Array.isArray(activity.result) ? activity.result : [ activity.result ];  
contacts.forEach(...)
```

So that you don't need to repeat the same code twice