changed temp algorithm