change randomly_permute_rows() procedure