refactoring to avoid unnecessary ajax  calls during autocomplete