add some console and fix some logic