Adding the structure traversal code and logic