improved autocomplete function sorting
further improved autocomplete