refactor logging