fixed bug in switch script generation