                     check_offers_finally(task_data)
                 end
         after 2_000 ->
-            coef = task_data.skill_sum / task_data.task
-            Logger.info "I'm DONE."
-                     <> "List of empls: #{inspect task_data.employers}\n"
-                     <> "Task: #{task_data.task} (#{coef})"
-        end
+            job_is_done task_data
+        end
+    end
+
+    def job_is_done task_data do
+        coef = task_data.skill_sum / task_data.task
+        Logger.info "I'm DONE."
+                 <> "List of empls: #{inspect task_data.employers}\n"
+                 <> "Task: #{task_data.task} (#{coef})"
     end
 
     def should_exchange? first, second do
-        {first_new, second_new} = exchange(first, second)
+        {first_new, second_new} = Tasks.exchange(first, second)
 
         old_disbalance = [first, second]
-                        |> Enum.map(&TaskProto.disbalance &1)
+                        |> Enum.map(&Tasks.disbalance &1)
                         |> Enum.sum
 
         new_disbalance = [first_new, second_new]
-                        |> Enum.map(&TaskProto.disbalance &1)
+                        |> Enum.map(&Tasks.disbalance &1)
                         |> Enum.sum
 
         new_disbalance < old_disbalance
-    end
-
-    def exchange data, other do
-        {m_e, m_updated} = data  |> TaskProto.pop_employer
-        {o_e, o_updated} = other |> TaskProto.pop_employer
-        m_new = m_updated |> TaskProto.push_employer(o_e)
-        o_new = o_updated |> TaskProto.push_employer(m_e)
-        {m_new, o_new}
     end
 
     def perfect_state _data do

                         <> "(#{List.first task_data.employers} and"
                         <> " #{List.first other_data.employers})."
                if should_exchange?(task_data, other_data) do
                    {new, oth_new} = exchange(task_data, other_data)
                    send pid, {:go, self(), oth_new}
                    receive do
                        :done ->
                            Logger.info "Exchange finished."
                                     <> "Now me:    #{inspect new}"
                                     <> "Now other: #{inspect oth_new}"
                            check_offers_finally(new)
                    after 1_000 ->
                            Logger.info "Exchange timeout."

                Logger.info "Received :deal_finished.\n"
                         <> "List of empls: #{inspect empls}\n"
                         <> "Task: #{task_data.task} (#{coef})"
                updated = task_data |> Tasks.push_remaining_tasks(tasks)
                try_exchange(updated)
        end
    end

    def try_exchange task_data do
        Logger.info "try_exchange"
        r = task_data |> Tasks.pop_remaining_task
        if is_nil(r) do
            Logger.info "We tried all tasks!"
            check_offers_finally(task_data)
        else
            {t, without_task} = r
            Logger.info "Only #{length without_task.remaining_tasks} tasks left"
            if t != self() do
                send t, {:go_exchange, self(), without_task}
                wait_agreement = fn itself ->
