implemented the control function
implemented the control function