Fix the restoring of the shuffle logic and add comment