change the timing of setting the environment variables