fixed a bug in the randomize functions