Change delay to 5 ms; 1 ms leaves the system unresponsive to quick changes in the switch.