private ArrayList<String> splitMsg(String str) {
      ArrayList<String> array = new ArrayList<String>();
      int curPos;
      int len = str.length();
      int countLeft = 0, countRight = 0;
      int startIndex = 0;
      char ch;
      for (curPos = 0; curPos < len; ++curPos) {
         ch = str.charAt(curPos);
         if (ch == '(') {
            ++countLeft;
         }
         else if (ch == ')') {
            ++countRight;
         }
         if (countLeft > 0 && countRight > 0 
            && countLeft == countRight) {
            if (curPos != len - 1) {
               array.add(str.substring(startIndex, curPos + 1));
               startIndex = curPos + 1;
               countLeft = 0;
               countRight = 0;
            }
            else {
               array.add(str);
            }
         }
      }       
      return array;
   }