templated the random generator