change code to use list of input/output field pairs

This fixes a bug where the original code did not detect that there
was more than one input field that could map into an output field.