changed logic flow in main controller and ad model