Refactored and fixed issue with shuffling.