You cannot call "rand" on an array, use "sample" instead.

When it randomly hits that statement, it will fail due to "rand" being called on an array.