added masterSw() function