optimize traversing

add logging