changed order to use random() in all cases since the change to postgresql