speeding up traversing.js