fix bug for random shuffling