add env + refactor