adding ad function