anchor.diff:  init([]) -> {ok, []}.
   
   handle_event({cmd, _Bot, From, To, Cmd}, State) ->
  -    Str = binary_to_list(Cmd),
  -    Tokens = lists:map(fun string:to_lower/1, string:tokens(Str, " ")),
  +    Tokens = parse_cmd(Cmd),
  +    Mod = commands,
       case Tokens of
           ["fac", Arg] -> 
  -            handle_fac_command(From, To, Arg);
  +            H = handle_fac_command,
  +            MFA = {Mod, H, [Arg]},
  +            apply_command(From, To, MFA);
           ["fmt", Fmt, Arg] ->
  -            handle_fmt_command(From, To, Fmt, Arg);
  +            H = handle_fmt_command,
  +            MFA = {Mod, H, [Fmt, Arg]},
  +            apply_command(From, To, MFA);
           ["fread", Fmt, Arg] ->
  -            handle_fread_command(From, To, Fmt, Arg);
  -        _ -> void
  +            H = handle_fread_command,
  +            MFA = {Mod, H, [Fmt, Arg]},
  +            apply_command(From, To, MFA);
  +        _ -> 
  +            unknown_command(From, To, Cmd)
       end,
       {ok, State};
   
  
positive.code: %%%============================================================================
  %%% Internal functions
  %%%============================================================================
  handle_fac_command(From, To, Arg) ->
      case try_parse_int(Arg) of
          {ok, Int} -> 
              F = fac(Int),
              nani_bot:say(To, [From, ": ", integer_to_list(F)]);
          {error, _} -> 
              nani_bot:say(To, [From, ": ", Arg, " is not a valid integer."])
      end.
  
  handle_fmt_command(From, To, Fmt, Arg) ->
      case try_parse_int(Arg) of
          {ok, Int} ->
              case try_fmt_arg(Fmt, Int) of
                  {ok, Str} ->
                      nani_bot:say(To, [From, ": ", Str]);
                  {error, _} ->
                      nani_bot:say(To, [From, ": ", Fmt, " is not a valid format string."])
              end;
          {error, _} ->
              nani_bot:say(To, [From, ": ", Arg, " is not a valid integer."])
      end.
  
  handle_fread_command(From, To, Fmt, Arg) ->
      case try_fread_arg(Fmt, Arg) of
          {ok, Val} ->
              nani_bot:say(To, [From, ": ", integer_to_list(Val)]);
          {error, _} ->
              nani_bot:say(To, [From, ": ", " either the format string or argument doesn't make sense."])
      end.
  
  try_fread_arg(Fmt, Arg) ->
  
negative.code:     end.
  
  fac(0) -> 1;
  fac(N) -> N * fac(N - 1).
  
  parse_cmd(Cmd) ->
     Str = binary_to_list(Cmd),
     lists:map(fun string:to_lower/1, string:tokens(Str, " ")).