     }
   end
 
-  def deal(data, bid_key, partner_key, id, bid, previous_bid, set) do
+  def deal(data, bid_key, partner_key, id, bid, set) do
     now = DateTime.today()
     id2 = data[bid_key].participant_id
     deals = [new_deal(data.counter, bid, id, id2, now) | data.deals]
     bids = List.delete(data[partner_key], data[bid_key])
     data = %{data | :deals => deals, partner_key => bids}
-           |> dealt(id, id2, bid)
+           |> dealt(id, id2, data[bid_key].bid)
            |> Map.update!(:counter, fn x -> x + 1 end)
     data = set.(data)
     data

      data[bid_key]
    end
    data = %{data | key => bids, bid_key => most_bid}
    data = update_in(data, [:participants, id], fn participant ->
      %{participant | bidded: true, bid: bid}
    end)
    data
    |> Map.update!(:counter, fn x -> x + 1 end)
  end

  def dealt(data, id1, id2, money) do
    data
    |> update_in([:participants, id1], fn participant ->
          %{participant | bidded: false, dealt: true, deal: money}
    end)
    |> update_in([:participants, id2], fn participant ->
          %{participant | bidded: false, dealt: true, deal: money}
