added function for randomization