refactoring the logging