fix logic in determining which factor is the Environment Name