refactor a bit buildAdapter