added a traverse function