bring back remove duplicate code for autocomplete, see #609