How does a relay work?