modified for trace analysis