refactor db_adapter