refactor debug