move _all_ env vars out of if block; small cleanup