Relay code loop issues

Looks correct to me, but variable waittime is going to get you into trouble if you ever use it.