added logic for sensing temperature