Improve error handling with empty data sets