anchor.diff:      {ok, ConnInfo} = get_connection_info(ServiceInfo),
       {ok, Cmd} = get_cmd(ServiceInfo),
       Connection = connect_to_service(ConnInfo),
  -    create_command_list_and_update_state(Cmd, UserInfo, ServiceInfo,
  +    create_command_and_update_state(Cmd, UserInfo, ServiceInfo,
                                            Connection, State).
   
   
  
positive.code:               Params::any(), Queue::binary(), pid()) -> {ok, map(), list()} |
                                         {error, any(), list()} | {error, atom()}.
  request(ServiceId, UserInfo, Params, Queue, Pid) ->
      try
          {ok, ServiceInfo} = watts_service:get_info(ServiceId),
          Timeout = maps:get(plugin_timeout, ServiceInfo, infinity),
          gen_server:call(Pid, {request_credential, ServiceInfo, UserInfo, Params,
                                Queue}, Timeout)
      catch
          exit:{timeout, _} ->
              UMsg = "the plugin timed out, please inform the administrator",
              LMsg = "request timed out",
              {ok, #{result => error, user_msg => UMsg, log_msg => LMsg}, []}
      end.
  
  
  -spec revoke(ServiceId :: binary(), UserInfo :: map(),
               CredState::any(), Queue::binary(), pid()) -> {ok, map(), list()} |
                                           {error, any(), list()}|{error, atom()}.
  revoke(ServiceId, UserInfo, CredState, Queue, Pid) ->
      try
          {ok, ServiceInfo} = watts_service:get_info(ServiceId),
          Timeout = maps:get(plugin_timeout, ServiceInfo, infinity),
          gen_server:call(Pid, {revoke_credential, ServiceInfo, UserInfo,
                                CredState, Queue}, Timeout)
      catch
          exit:{timeout, _} ->
              UMsg = "the plugin timed out, please inform the administrator",
              LMsg = "revoke timed out",
              {ok, #{result => error, user_msg => UMsg, log_msg => LMsg}, []}
      end.
  
  -spec get_params(ServiceId ::any(), Pid::pid()) -> {ok, map()} |
                                                     {error, atom(), list()} |
                                                     {error, atom()}.
  get_params(ServiceId, Pid) ->
      try
          {ok, ServiceInfo} = watts_service:get_info(ServiceId),
          Timeout = maps:get(plugin_timeout, ServiceInfo, infinity),
          gen_server:call(Pid, {get_params, ServiceInfo}, Timeout)
      catch
          exit:{timeout, _} ->
              UMsg = "the plugin timed out, please inform the administrator",
              LMsg = "params timed out",
              {ok, #{result => error, user_msg => UMsg, log_msg => LMsg}, []}
      end.
  
  
  
negative.code:     Update = #{watts_userid => UserId, user_info => PluginUserInfo},
      maps:merge(ScriptParam, Update).
  
  execute_command(Cmd, ssh, Connection, State) when is_list(Cmd) ->
      {ok, ChannelId} = ssh_connection:session_channel(Connection, infinity),
      lager:debug("runner ~p: executing ~p", [self(), Cmd]),
      success = ssh_connection:exec(Connection, ChannelId, Cmd, infinity),
      CmdOutput =  #{channel_id => ChannelId, cmd => Cmd},
      {ok, State#state{ cmd_output = CmdOutput }};
  execute_command(Cmd, local, _Connection, State) when is_list(Cmd) ->
      lager:debug("runner ~p: executing ~p", [self(), Cmd]),
      StdOut = list_to_binary(os:cmd(Cmd)),
      lager:debug("runner ~p: result ~p", [self(), StdOut]),
      CmdOutput = #{std_out => [StdOut], cmd => Cmd, std_err => []},
      NewState = State#state{ cmd_output = CmdOutput },
      trigger_sending(),
      {ok, NewState};
  execute_command(Cmd, ConType, Connection, State)
    when is_binary(Cmd) ->
      execute_command(binary_to_list(Cmd), ConType, Connection, State).
  
  
  
  send_result(#state{ cmd_output = CmdOutput, connection = Connection,
                      con_type = ConType} = State) ->
      lager:debug("runner ~p: execution done, closing connection", [self()]),
      close_connection(Connection, ConType),
      Result = create_result(CmdOutput),
      lager:debug("runner ~p: sending result ~p", [self(), Result]),
      {ok, NewState} = send_reply(Result, State),
      {stop, normal, NewState}.
  
  create_result(#{exit_status := 0, std_out := []} = Output) ->
      {error, no_json, Output};
  create_result(#{exit_status := 0, std_out := [Json|_]} = Output) ->
      case jsone:try_decode(Json, [{keys, attempt_atom}, {object_format, map}]) of
          {ok, Map, _} -> {ok, Map, Output};
          {error, _} -> {error, bad_json_result, Output}
      end;
  create_result(#{exit_status := _} = Output) ->
      {error, script_failed, Output};
  create_result(#{std_err := []} = Output) ->
      create_result(maps:put(exit_status, 0, Output));
  create_result(Output) ->
      create_result(maps:put(exit_status,-1, Output)).
  
  
  
  
  handle_ssh_message({data, ChannelId, 0, Data}, ChannelId, State) ->
  