Extracted some environment verification logic