added error logging to the try catch finally