working matrixs randomize function