Adding error handling.
Adding error handling.