moved autocomplete into it's own function