I’m actually just helping somebody do something similar look at the test2.C in this post:
Cheers, Matevz