Moved the function which saves logs