Added error checking for missing fields.