modify print_trace to reduce complexity