Adding error handling.