WIP: Thermostat algorithm