     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)

			true -> f.(g)
		end
	end
	def positive_balances_1_5(txs, acc, block_creator, bond_size, cost) do
    balance = [cash: acc.amount, bond: acc.bond]
    addresses = [{block_creator, balance}]
    positive_balances_2(txs, bond_size, block_creator, cost, addresses)
  end
  def positive_balances_2(txs, bond_size, block_creator, cost, addresses) do
    cond do
      txs==[] ->
				if block_creator != nil do
          addresses = lose_cash(addresses, block_creator, cost) 
        end
				#IO.puts("verify balances #{inspect addresses}")#verify balances [{"BCmhaRq42NNQe6ZpRHIvDxHBThEE3LDBN68KUWXmCTKUZvMI8Ol1g9yvDVTvMsZbqHQZ5j8E7sKVCgZMJR7lQWc=", [cash: 1999999689989990.0, bond: 99734203939204.69]}, {"BDju4ADMQhB0DtzrM8BeVHZlVD74QVKXCfhpcvH8yg5/7yaOK7/e6mig4RC8WVpaVowInI4lMMHlV/UJKbEtBck=", [cash: 10, bond: 0]}, {:bond, [bond: 99734203939204.69, cash: 1999999689989990.0]}, {:cash, [cash: -61999990, bond: 0]}]
        all_positive(addresses)
      true -> positive_balances_1(txs, bond_size, block_creator, cost, addresses)
    end

defmodule VerifyBalances do
	def all_positive(a) do
		a |> Enum.map(fn({_, x}) -> x[:cash] >= 0 and x[:bond] >= 0 end)
		|> Enum.reduce(true, &(&1 and &2))
	end
	def lose_cash(addresses, pub, amount) do
		acc = HashDict.get(addresses, pub)
		HashDict.put(addresses, pub, [cash: acc[:cash]-amount, bond: acc[:bond]])
	end
	def lose_bond(addresses, pub, amount) do
		acc = HashDict.get(addresses, pub)
		HashDict.put(addresses, pub, [cash: acc[:cash], bond: acc[:bond]-amount])
	end
  def positive_balances(txs, bond_size, block_creator, cost) do
		f = fn(acc) ->
			addresses = HashDict.put(%HashDict{}, block_creator, [cash: acc.amount, bond: acc.bond])
			positive_balances_2(txs, bond_size, block_creator, cost, addresses)
		end
		g = KV.get(block_creator)
		cond do
			block_creator == ""  ->
