Creation of control function