Rewrite shuffle and mutate functions