beginning of relay v2 code