added failsave behaviour with try statements to prvent closing of the app