smooth the logic & debug: avoid some loops.