Adding some error handling.