replaced rand with mt_rand fucntion