begin refactor debug