diff --git a/app/assets/javascripts/contact-list.js b/app/assets/javascripts/contact-list.js
index 3dfa85dc50c075151f3926e6e0513b723cd2f2f0..87740a64aea55f782daee5a924ec35689728fc25 100644
--- a/app/assets/javascripts/contact-list.js
+++ b/app/assets/javascripts/contact-list.js
@@ -30,4 +30,10 @@ var List = {
     setTimeout( "List.runDelayedSearch('" + theSearch + "')", 10000);
   }
 };
+
+$(document).ready(function() {
+  if (gon.preloads.background_query) {
+    List.startSearchDelay(gon.preloads.background_query);
+  }
+});
 // @license-end
diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb
index 303423aa81eb361fd549455f466956e0439b0984..930ed0b7cd26a0fbb605e7b0a3c5ba62d54d8ab7 100644
--- a/app/controllers/people_controller.rb
+++ b/app/controllers/people_controller.rb
@@ -39,13 +39,10 @@ class PeopleController < ApplicationController
       end
 
       format.any(:html, :mobile) do
-        #only do it if it is an email address
+        # only do it if it is a diaspora*-ID
         if diaspora_id?(search_query)
           @people = Person.where(diaspora_handle: search_query.downcase, closed_account: false)
-          if @people.empty?
-            Workers::FetchWebfinger.perform_async(search_query)
-            @background_query = search_query.downcase
-          end
+          background_search(search_query) if @people.empty?
         end
         @people = @people.paginate(:page => params[:page], :per_page => 15)
         @hashes = hashes_for_people(@people, @aspects)
@@ -167,6 +164,12 @@ class PeopleController < ApplicationController
     raise Diaspora::AccountClosed if @person.closed_account?
   end
 
+  def background_search(search_query)
+    Workers::FetchWebfinger.perform_async(search_query)
+    @background_query = search_query.downcase
+    gon.preloads[:background_query] = @background_query
+  end
+
   def hashes_for_people(people, aspects)
     people.map {|person|
       {
diff --git a/app/views/people/index.html.haml b/app/views/people/index.html.haml
index 5dd55ddbf707b46113f12a5d3e9619c9495ed4a2..a3c19c069f33eca5ea627a412525216d8eac7c26 100644
--- a/app/views/people/index.html.haml
+++ b/app/views/people/index.html.haml
@@ -16,20 +16,12 @@
     .col-md-8
       #people_stream.stream
         - if @hashes.empty?
-          - if @background_query.present?
-
-            / TODO this is gross, and should be extracted!
-            :javascript
-              $(document).ready( function() {
-                List.startSearchDelay('#{@background_query}')
-              } );
-
-            %p
+          %p
+            - if @background_query.present?
               = t(".searching")
               .loader
                 .spinner
-          - else
-            %p
+            - else
               = t('.no_one_found')
         - else
           - for hash in @hashes