modified profiler to merge efficiently