Make changes as commented by @zenden2k

I've updated the check here to be more cautious; no harm in checking to see if the fields exist before trying to use them!