Refactor autocomplete with jQuery