Simplifying things to search.js

As I said on the commit, the purpose of this PR is to get things simpler on search.js.

If you think that the first commit is unnecessary and it's not fair to merge with its existance, just let me know that I make a third PR, with a clean/new fork.
this looks broken