refactoring based on generic ad plugin common code