Rearranged the if/then statements and uncommented the relay lines.