remove some calls to rand()