Modified code to deal with unknown record types