changes to random traversal function