added error handling to app controller