add debug mode and fix merge conflict