added shuffle option for unspecified k