code moved from stress_test to __main__