ADDED error handling