added traversal function