added code to implement waiting, causing the LED to flash on and off