optimize switch mode