shared methods for autocomplete and textcomplete