Uses ruby rand() instead of MySQL random() to improve compatability