fixes to rand