Updating
Adding error handling
added error handling