New refactor of autocomplete