Refactor env