fix bug in trace operation