refactor debug & logger