introduce stopper in dfs
use stopper for speed.
inline to make interface simpler