added traverse function