Add logic of controller and flex adapter