Changed rand to mt_rand