anchor.diff:    mongo_do(State, copilot, fun () -> mongo:save(connections, Doc) end);
   handle_cast({disconnect, {User, Host, Resource} = JID, IPAddress}, State) ->
     mongo_do(State, copilot, fun () ->
  -    JIDString = User ++ "@" ++ Host ++ "/" ++ Resource,
  -    Cursor = mongo:find(connections, {user, User,
  -                                      host, Host,
  -                                      resource, Resource
  +    Cursor = mongo:find(connections, {user, utf8(User),
  +                                      host, utf8(Host),
  +                                      resource, utf8(Resource),
                                         connected, true}),
       NewDoc = doc_close_connection(mongo:next(Cursor), JID, IPAddress),
       mongo:close_cursor(Cursor),
  
positive.code:   Lng = proplists:get_value(longitude, GeoData),
    Lat = proplists:get_value(latitude, GeoData),
  
    {user, User,
     host, Host,
     resource, Resource,
     loc, [Lng, Lat],
     connected_at, bson:timenow(),
     connected, true}.
  
  %@doc Marks connection as closed and appends data from agent's JID
  doc_close_connection({ok, {}}, JID, IPAddress) ->
  
negative.code: 
  %@doc Handles presence stanzas sent by users
  handle_presence(UserState, {User, Server, Resource} = JID) ->
    {IPAddress, _} = ejabberd_sm:get_user_ip(User, Server, Resource),
    ?DEBUG("User ~p (~p) is ~p", [JID, IPAddress, UserState]),
  
    % Passes over the processing into a new process
    % Strings are converted to utf8 because of MongoDB driver
    gen_server:cast(?MODULE, {UserState, JID, IPAddress}),
    report_event(Server, atom_to_list(UserState)),
    ok.
  
  %%% gen_server %%%
  