Moved temperature check to new function