Encapsulate completely in autocomplete function