Refactured the search script, but it still doestn't work.