refactor env