refactoring and adding environment