consolidating code for controls