fixed shuffle function