public static boolean check_cmd(String line) {
    // must have the length of 3 or 4
    String line_test = line;
    String[] line_arr = line.split("\\s+");
    int line_length = line_arr.length;

    if (line_length != 3 && line_length != 4) {

      // it's a bad instruction!
      BadInstructionObject bad_inst = new BadInstructionObject();

      // set InstructionObject as "bad"
      inst_obj.set_type("bad");

      // feed to BadInstrution to ReferenceManager
      ref_mgr.badInst(bad_inst);

      // print state
      printState();

      return false;
    }

    // must have read or write in the first command
    if ((!line_arr[0].toLowerCase().equals("read"))
        && (!line_arr[0].toLowerCase().equals("write"))) {

      // it's a bad instruction!
      BadInstructionObject bad_inst = new BadInstructionObject();
      inst_obj.set_type("bad");

      // feed to ReferenceManager
      ref_mgr.badInst(bad_inst);

      // print state
      printState();

      return false;
    }

    // format = string string string int, where int is optional
    try {
      Integer.parseInt(line_arr[1]);
      // it's a bad instruction!
      BadInstructionObject bad_inst = new BadInstructionObject();

      inst_obj.set_type("bad");

      // feed to Reference Manager
      ref_mgr.badInst(bad_inst);

      // print state
      printState();

      return false;
    } catch (Exception e) {
      // it is not an int! good! do nothing
    }

    try {
      Integer.parseInt(line_arr[2]);

      // it's a bad instruction!
      BadInstructionObject bad_inst = new BadInstructionObject();
      inst_obj.set_type("bad");

      // feed to Reference Manager
      ref_mgr.badInst(bad_inst);

      // print state
      printState();

      return false;
    } catch (Exception e) {
      // it is not an int! good! do nothing
    }

    if (line_arr.length == 4) {
      if (!line_arr[0].toLowerCase().equals("write")) {

        // it's a "read" command with 4 length. INVALID!
        // it's a bad instruction!
        BadInstructionObject bad_inst = new BadInstructionObject();

        inst_obj.set_type("bad");

        // feed to Reference Manager
        ref_mgr.badInst(bad_inst);

        // print state
        printState();

        return false;
      }

      try {
        cmd_value = Integer.parseInt(line_arr[3]);
        // it is an int! good! do nothing!
        // save!
        main_cmd = line_arr[0] + "s";
      } catch (Exception e) {
        // last command is  NOT int
        // it's a bad instruction!
        BadInstructionObject bad_inst = new BadInstructionObject();

        inst_obj.set_type("bad");

        // feed to Reference Manager
        ref_mgr.badInst(bad_inst);

        // print state
        printState();

        return false;
      }
    } else {
      if (!line_arr[0].toLowerCase().equals("read")) {

        // it's a "read" command with 4 length. INVALID!
        // it's a bad instruction!
        BadInstructionObject bad_inst = new BadInstructionObject();

        inst_obj.set_type("bad");

        // feed to Reference Manager
        ref_mgr.badInst(bad_inst);

        // print state
        printState();

        return false;
      }
      main_cmd = line_arr[0] + "s";
    }

    // save global for later use
    subject_name = line_arr[1];
    object_name = line_arr[2];
    cmd_length = line_arr.length;

    return true;
  }