added backtracking to random traversal