Added checks to nto run finnish loggin unles the function exists