added traverse function with callback