refactor to support custom adapters