rewrite term autocomplete so as to use the library code