restructuring to do pre/post traversals