random number range adaptive

the random number generator will now pick a number between 0 and the
number of objects in the dictionary.