refactoring of auto completion