Improvement to autocomplete query