the code is supposed to take a string and tokenize it such that if the input string = "hello world here I am", cmd_argv[0] = "hello"
cmd_argv[1] = "world"
cmd_argv[2] = "here I am" 
and if input string = "hello world"
cmd_argv[0] = "hello"
cmd_argv[1] = "world"
cmd_argv[2] = NULL
but for the second example, I still get 3 values. What is the error?
int cmd_argc = 0;
char *next_token = strtok(cmd, DELIM);
while (next_token != NULL && cmd_argc < 3) {
    cmd_argv[cmd_argc] = next_token;
    cmd_argc++;
    if (cmd_argc == 2) {
        char *rest = strtok(NULL, "");
        cmd_argv[cmd_argc - 1] = strndup(cmd_argv[cmd_argc - 1], rest - cmd_argv[cmd_argc - 1] - 1);  // ???
        cmd_argv[cmd_argc] = rest;
        cmd_argc++;
    }
    next_token = strtok(NULL, DELIM);
}