use debug to replace some console.log to show debug info