added error handling for data