implemeting traverse.