Added temperature deciding algorithm in State