better error handling for missing data