Refactored check-environment task