updated shuffle function