Handles errors more elegantly.