     }
   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

      # Seller
      %{role: "seller", bidded: bidded, bid: previous_bid, money: money, dealt: false} when not is_nil(money) and bid >= money ->
        data = remove_first(data, id, previous_bid, :lowest_bid, :seller_bids, &set_lowest_bid/1)
        if not is_nil(data.highest_bid) and bid <= data.highest_bid.bid do
          deal(data, :highest_bid, :buyer_bids, id, bid, previous_bid, &set_highest_bid/1)
        else
          bid(data, :lowest_bid, :seller_bids, id, bid, previous_bid, "NEW_SELLER_BIDS", fn most_bid, bid ->
            bid < most_bid

  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}
