move control logic to own class