Added shuffle and reshuffle logic.