added switch control structure