fix multiple bugs with shuffling