how does a relay work