Use crypto:rand_uniform()