refactor debug text into a separate method