Add error handling in controller