The variable a is only for the relay function to run once. This code seems to work. Also, thanks for your ideas.