Refactor the profiler