factor out adapter creation