api v2 - initial refactoring of env controller