changed rand() to mt_rand()