Enhance the implementation of traverse