Fixed issue with autocomplete function