Making the shuffle algorithm non-desctructive