added other data types and mat changed to rnd