Create macro for setting fields and add joint functions