Refactoring of setenv template