analyze and optimize switches