changed envvars replacement logic