Refactor logger