Refactor asyncSearch.js