Refactored code to use one function for autosuggest filter.