Reseting array to empty should be done outside the `if (prefixes.length)` block, so Array is also reset if empty.