replace profiling script with context manager