fix wrong code
still some issues in trace method