Modify script according to controls