randomize implementation