correct error handling in controllers