fix call to rand()