fixed a bug in shuffle