correctly compute sw_trace_nd