Refactored Autocomplete functionality to be reusable.