Created single search.js file to remove some code duplication