refactor new debugtext code