made addenvironment more flexible