correction with switch optimization: 4.66 s