got it all working (i think!)