       loop(state)
     end
 
-    def handle_result([_result_id, _options, _arguments, %{"result" => res}]) do
-      Logger.info("<Caller> received result: #{inspect(res)}")
+    def handle_result(state, [_result_id, _options, _arguments, %{"result" => res}]) do
+      Logger.info("<Caller: #{inspect(state.caller)}> received result: #{inspect(res)}")
     end
   end
 

      # `Spell.cast_call` performs an asyncronous call to the remote procedure, the result will 
      # be intercepted and parsed by the block `Spell.receive_result`
      {:ok, call_id} = Spell.cast_call(state.caller, state.procedure, state.params)
      Logger.info("<Caller> send params: #{inspect(state.params)}")
      
      case Spell.receive_result(state.caller, call_id) do
        {:ok, result} -> IO.inspect handle_result(result)
        {:error, reason} -> {:error, reason}
      end



      # `Spell.cast_register` receive the callee and the procedure where it
      # has to be registered
      {:ok, _reg_id} = Spell.cast_register(callee, procedure)

      %__MODULE__{callee: callee} |> struct(options) |> loop()
    end

    defp loop(state) do
      receive do
        :stop -> :ok
        {Spell.Peer, _pid, message} -> state = handle_message(state, message)
        _ -> {:error, :wrong_message}
      after
        state.timeout -> {:error, :timeout}
