I can confirm that this revised Sketch compiles and loads with Arduino 1.8.1 on Mac and Windows 10.
I did have to do a major search to find a cure for no serial ports identified as targets under Arduino/Mac. Finally found a Signed driver for the CH340/341 chipset on my Nano.
Tom
KF7RSF