Yes, my code is quite convoluted, Henrik. I haven't written code for at least 15 years, and I have never written code for PIC. Because of certain physical limitations, the canned BUTTON and TOGGLE commands don't work well or could create potential problems. The latching relay could be accidentally flipped by ESD or a magnetic field or a power spike, which would cause the relay's state to be out of sync with the LED. Instead of adding some sort of reset code or feature, I've tried to create my own "toggle" command that inherently resets the LATCH variable every time the button is pressed according to the state of the LED. That is the reason for the use of the word variable. But perhaps a bit or byte variable would work just as well. I don't know. That is my lack of experience.