Maybe combine this condition with the previous one, since they have the same container?
```
else if (type == 'peer' || type == 'self')
```