random_sel changed
bug in computation of num_vist fixed