Refactor environment commands