Refactor logging part2