adapter detection refactoring