added flip function to Relay