code working in OUTPUTMODE_INSTANT_SWITCH mode