Minor optimization

Move loop invariant code.
No, actually this would be best.

```js
if (!Array.isArray(excludes)) {
  excludes = [];
}
```