Refactor the environment command