Adding an error handling