Refactoring, add logger