Accommodate situation where the user has no thermostats but only detectors; improved loop variable names for readability.