fixed bug in shuffle function