refactored ad helper