untested code for inserting fields