Refactoring for logging