optimized switch: 4.59 s