Refactoring the environment class