update error handling in controllers