Added error handle in controller for the app