added error handling to initApp