updated thermostat function