Added null check for fieldnames as some field names were empty ""