Control Function added

changed a bit of alex's code to work with control class