anchor.diff:  
   handle_message(Worker,?REQ, ?GRAB_JOB,_Data)->
       ?DEBUG("==> worker: ~p GRAB_JOB~n", [Worker]),
  -    Work = find_work(Worker),
  +    Work = erlang_db:assign_work(Worker),
       if Work =:= null ->       
               ?DEBUG("<== worker: ~p NO_JOB~n", [Worker]),
               send_response(Worker,?NO_JOB,<<>>);
          true ->
               Workload = list_to_binary([Work#work.id,0,Work#work.name,0,Work#work.data]),
  -
  -            % update our state to mark the worker busy so we dont send it more work
  -            WorkerRec = #worker{sock=Worker,state=busy},
  -            % also update our job queue so we dont reassign the job to someone else
  -            WorkRec = Work#work{assigned=Worker},
  -            mnesia:transaction(fun() -> mnesia:write(WorkerRec), mnesia:write(WorkRec) end),
  -
               ?DEBUG("<== worker: ~p JOB_ASSIGN~n", [Worker]),
               send_response(Worker, ?JOB_ASSIGN, Workload)
       end;
  
positive.code: wakeup_worker(Job) ->
      wakeup ! {self(),Job}.
      
  find_worker(Job) ->
      Workers = dbq(qlc:q([W#worker.sock || W <- mnesia:table(worker),
                                            W#worker.state =:= ready,
                                            F <- mnesia:table(function),
                                            W#worker.sock =:= F#function.sock,
                                            F#function.name =:= Job#work.name ])),
      case Workers of
          [] -> null;
          Workers -> hd(Workers)
      end.
  
  find_work(Worker) ->
      Now = now(),
      Jobs = dbq(qlc:keysort(2,
                             qlc:q([J || J <- mnesia:table(work),
                                         J#work.assigned =:= null,
                                         J#work.schedule =< Now,
                                         F <- mnesia:table(function),
                                         F#function.sock =:= Worker,
                                         J#work.name =:= F#function.name
                                   ]))),
      case Jobs of
          [] -> null;
          Jobs -> hd(Jobs)
      end.
  
  findDelimiters(Bin,Delim,Lim) ->
      findDelimiters(Bin,Delim,Lim,1,[]).
  
  
negative.code: handle_message(Worker,?REQ, ?CAN_DO, Data)->
      ?DEBUG("==> worker register: ~p~n",[Data]),
      % load out new worker into the DB
      erlang_db:worker_register(Worker,Data);
  
  handle_message(Worker,?REQ,?CANT_DO,Data) ->
      ?DEBUG("==> worker unregister: ~p~n",[Data]),
      erlang_db:worker_unregister(Worker);
  
  % this is a SYNC job, it will not be inserted into the queue
  handle_message(Client, ?REQ, ?SUBMIT_JOB, Data)->
  