code to trace path