     if not pub in Dict.keys(addresses) do
       acc = KV.get(pub)
       balance = [cash: acc.amount, bond: acc.bond]
-      addresses = [{pub, balance}|addresses]
+			addresses = HashDict.put(addresses, pub, balance)
     end
     case da.__struct__ do
       :Elixir.Spend        -> addresses = lose_cash(addresses, pub, da.amount+da.fee)

defmodule VerifyBalances do
  def all_positive(a) do
    cond do
      a == [] -> true
      true -> all_positive_1(a)
    end
  end
  def all_positive_1(addresses) do
    [{_, t}|tail] = addresses
    cond do
      t < 0 -> false
      tail == [] -> true
      true -> all_positive_1(tail)
    end
  end
  def get([head|tail], key) do
    {k, v} = head
    cond do
      k==key -> v
      true -> get(tail, key)
    end
  end
  def put(l, key, value) do
    cond do
      l==[] -> [{key, value}]
      key == elem(hd(l), 0) -> [{key, value}|tl(l)]
      true -> [hd(l)|put(tl(l), key, value)]
    end
  end
  def modify_balance(addresses, pub, f, key) do
    balance = get(addresses, pub)
    balance = f.(balance)
    [{key, balance}|addresses]
    put(addresses, key, balance)
  end
  def lose_key(address, pub, amount, key) do
    f = fn(balance) ->
      Dict.put(balance, key, Dict.get(balance, key) - amount) 
    end
    modify_balance(address, pub, f, key)
  end
  def lose_cash(address, pub, amount) do
    lose_key(address, pub, amount, :cash)
  end
  def lose_bond(address, pub, amount) do
    lose_key(address, pub, amount, :bond)
  end
  def positive_balances(txs, bond_size, block_creator, cost) do
		f = fn(acc) -> positive_balances_1_5(txs, acc, block_creator, bond_size, cost) end
		g = KV.get(block_creator)
		cond do
			block_creator == ""  ->

			true -> f.(g)
		end
	end
  def positive_balances_2(txs, bond_size, block_creator, cost, addresses) do
    cond do
      txs==[] ->
				if block_creator != "" do
          addresses = lose_cash(addresses, block_creator, cost) 
        end
        all_positive(addresses)
      true -> positive_balances_1(txs, bond_size, block_creator, cost, addresses)
    end
