private static void merge(int[] a, int[] aux, int lo, int mid, int hi)
   {
      // DK: add two tests to first verify "mid" and "hi" are in range
      if (mid >= a.length) return;
      if (hi > a.length) hi = a.length;
      int i = lo, j = mid;
      for (int k = lo; k < hi; k++) {
         if      (i == mid)     aux[k] = a[j++];
         else if (j == hi)      aux[k] = a[i++];
         else if (a[j] < a[i])  aux[k] = a[j++];
         else                   aux[k] = a[i++];
      }
      // copy back
      for (int k = lo; k < hi; k++)
      {
         a[k] = aux[k];
      }
   }