improved traversal.js