refactor code to account for missing fields