fixed division by zero in random number gen