replace rand() by Array#sample