       # 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)
+                |> update_bid(id, bid)
         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)
+          deal(data, :highest_bid, :buyer_bids, id, 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

        end
    end
    data
  end

  def remove_first(data, id, previous_bid, bid_key, key, set) do

    }
  end

  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, data[bid_key].bid)
           |> Map.update!(:counter, fn x -> x + 1 end)
    data = set.(data)
    data
