fixed end of trace and sign problem