updated traverse helper method