adding a new variable that records the length of traceRoot