refactor Environment funs