added generic version of shuffle