add some defensive checks when iterating through fields