refactored trace_file.py