added control logic