refactor ad framework