fixed randomize bugs