replacing rand with mt_rand